feat: assets-controllers extract and export getAssetId#9386
Conversation
|
@metamaskbot publish-preview |
| */ | ||
| const chainIdToNativeTokenAddress: Record<Hex, Hex> = { | ||
| '0x89': '0x0000000000000000000000000000000000001010', // Polygon | ||
| '0x1e': '0x542fda317318ebf1d3deaf76e0b632741a7e677d', // Rootstock Mainnet - Native symbol: RBTC |
There was a problem hiding this comment.
Rootstock native address mapping removed
Medium Severity
The Rootstock (0x1e) entry was removed from chainIdToNativeTokenAddress, so getNativeTokenAddress now returns the zero address instead of RBTC’s contract address. Native detection in getAssetId and market-data keys in TokenRatesController no longer match wallets that still use the RBTC address, which can misclassify native RBTC as ERC-20 or drop prices.
Reviewed by Cursor Bugbot for commit 99313eb. Configure here.
There was a problem hiding this comment.
0x542fda317318ebf1d3deaf76e0b632741a7e677d has never been the native.
99313eb to
734dfcf
Compare
|
Preview builds have been published. Learn how to use preview builds in other projects. Expand for full list of packages and versions. |
|
@metamaskbot publish-preview |
|
Preview builds have been published. Learn how to use preview builds in other projects. Expand for full list of packages and versions. |
c152079 to
c6bc289
Compare
|
@metamaskbot publish-preview |
|
Preview builds have been published. Learn how to use preview builds in other projects. Expand for full list of packages and versions. |
|
@metamaskbot publish-preview |
|
Preview builds have been published. Learn how to use preview builds in other projects. Expand for full list of packages and versions. |


Explanation
Extract
getAssetIdfrom thefetchTokenPricesso it can be reused later not only for v3 Spot Prices but also V3 historical prices.Extension draft client: MetaMask/metamask-extension#44161
Mobile draft client: MetaMask/metamask-mobile#32796
Added
getAssetIdincodefi-v2.tsfor CAIP-19 asset ID derivation - extracted from existingfetchTokenPrices(#9386)Changed
988), Rootstock (30) and Gnosis (100) incodefi-v2.ts(#9386)References
Checklist
Note
Medium Risk
Changes how native tokens on Gnosis, Stable, and Rootstock are detected and which CAIP-19 IDs are sent to the price API, which can affect displayed fiat values if mappings are wrong.
Overview
Exports
getAssetIdfromcodefi-v2.tsso clients can derive the same CAIP-19 asset IDs used by Codefi spot pricing (including for planned v3 spot/historical flows).CodefiTokenPricesServiceV2.fetchTokenPricesnow calls this helper instead of inlined logic; behavior is intended to match aside from the mapping updates below.Native / price API identifier changes: Rootstock, Gnosis, and Stable are no longer in the custom
chainIdToNativeTokenAddressmap (native is treated as the zero address like most EVM chains).SPOT_PRICES_SUPPORT_INFOupdates Gnosis and Stable native IDs toerc20:0x000…0000instead of slip44 or a chain-specific ERC-20 address; Rootstock keeps its slip44 entry but loses the custom native address override.Changelog and package exports (
token-prices-service, mainindex) includegetAssetId; unit tests cover ERC-20, native, fallbacks, and invalid input.Reviewed by Cursor Bugbot for commit 21e81e2. Bugbot is set up for automated code reviews on this repo. Configure here.